//导入axios工具包
import instance from '@/utils/axios.js'

/* 登录接口 */
function getLogin ({ mobile, code }) {
  return instance({
    url: '/v1_0/authorizations',
    method: 'post',
    data: {
      mobile, // mobile: mobile
      code
    }
  })
}
//导出接口
export { getLogin }

import { getToken } from '@/utils/token.js'
//获取个人信息
function getUserInfo () {
  return instance({
    url: '/v1_0/user/profile',
    method: 'get',
    headers: {
      Authorization: `Bearer ${getToken().token}`
    }
  })
}
//导出接口
export { getUserInfo }

//修改个人信息
function editUserInfo (obj) {
  return instance({
    url: '/v1_0/user/profile',
    method: 'patch', //patch请求玉post请求传参方式一致
    data:obj,
    headers: {
      Authorization: `Bearer ${getToken().token}`
    }
  })
}

export { editUserInfo }

//修改用户头像
function editPhoto(fd) {
  return instance({
    url: '/v1_0/user/photo',
    method: 'patch', //patch请求玉post请求传参方式一致
    data:fd,
    headers: {
      Authorization: `Bearer ${getToken().token}`
    }
  })
}

export { editPhoto }
